package com.blb.community_admin.entity;


import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * @author hkp
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SysLogininfor {

    @ExcelProperty("访问ID")
    @TableId(type = IdType.AUTO)
    private long infoId;
    @ExcelProperty("用户账号")
    private String userName;
    @ExcelProperty("登录IP地址")
    private String ipaddr;
    @ExcelProperty("登录地点")
    private String loginLocation;
    @ExcelProperty("浏览器类型")
    private String browser;
    @ExcelProperty("操作系统")
    private String os;
    @ExcelProperty("登录状态（0成功 1失败）")
    private String status;
    @ExcelProperty("提示消息")
    private String msg;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ExcelProperty("访问时间")
    private LocalDateTime loginTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        SysLogininfor that = (SysLogininfor) o;
        return Objects.equals(userName, that.userName);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userName);
    }
}
